<template>
  <el-dialog
    v-if="show"
    v-model="dialog"
    title="审核详情"
    class="ExamineDetailDialog"
    width="65%"
    :close-on-click-modal="false"
    top="10vh"
    :before-close="handleClose"
  >
    <el-row :gutter="20" v-if="detailData">
      <el-col :span="16">
        <div class="my_card">
          <div class="header">申请人基本信息</div>
          <el-row class="elrow flexBetween">
            <div class="avatarBox">
              <el-avatar
                :size="80"
                src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
              />
            </div>
            <div class="rightBox">
              <el-col :span="6">
                <div class="title">申请人</div>
                <span>{{ detailData.name }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">年龄</div>
                <span>无</span>
              </el-col>
<!--              <el-col :span="6">-->
<!--                <div class="title">申请类别</div>-->
<!--                <span>自有车申请</span>-->
<!--              </el-col>-->
<!--              <el-col :span="6">-->
<!--                <div class="title">车牌号码</div>-->
<!--                <span>无</span>-->
<!--              </el-col>-->
              <el-col :span="6">
                <div class="title">性别</div>
                <span>{{ detailData.sex == 1 ? '男' : '女' }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">UID</div>
                <span>{{ detailData.id }}</span>
              </el-col>
              <el-col :span="6">
                <div class="title">联系电话</div>
                <span> {{ detailData.mobileNo }}</span>
              </el-col>
<!--              <el-col :span="6">-->
<!--                <div class="title">车辆年限</div>-->
<!--                <span>无</span>-->
<!--              </el-col>-->
            </div>
          </el-row>
        </div>
      </el-col>

      <el-col :span="8">
        <div class="my_card">
          <div class="header">申请人基本信息</div>
          <el-row class="elrow">
            <div class="flexBetween">
              <p>申请时间</p>
              <p>{{ detailData.registerTime }}</p>
            </div>
            <div class="flexBetween">
              <p>申请形式</p>
              <p>无</p>
            </div>
            <div class="flexBetween">
              <p>邀请人</p>
              <p>无</p>
            </div>
          </el-row>
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="16">
        <div class="my_card">
          <div class="header">申请证件信息</div>
          <el-row class="elrow">
            <el-col :span="8">
              <div class="title">个人身份证信息</div>
            </el-col>
            <el-col :span="16">
              {{ detailData?.idNo }}
            </el-col>
            <el-col :span="8">
              <div class="title">身份证照片</div>
            </el-col>
            <!--            {{ detailData?.drivingLicenseTopsideUrl }}-->
            <el-col :span="16">
              <el-image style="width: 320px; height: 200px"
                        :src= detailData?.idCardTopsideUrl
                        fit="contain" />.
              <el-image style="width: 320px; height: 200px"
                        :src= detailData?.idCardBacksideUrl
                        fit="contain" />
            </el-col>

<!--            <el-col :span="8">-->
<!--              <div class="title">身份证照片</div>-->
<!--            </el-col>-->
<!--            <el-col :span="16">-->
<!--              <el-image-->
<!--                style="width: 180px; height: 100px"-->
<!--                :src="detailData?.drivingLicenseTopsideUrl"-->
<!--                fit="contain"-->
<!--              />-->
<!--              <el-image-->
<!--                style="width: 180px; height: 100px"-->
<!--                :src="detailData?.drivingLicenseBacksideUrl"-->
<!--                fit="contain"-->
<!--              />-->
<!--            </el-col>-->
<!--            <el-col :span="8">-->
<!--              <div class="title">车辆品牌及型号</div>-->
<!--            </el-col>-->
<!--            <el-col :span="16"> 无 </el-col>-->

            <el-col :span="8">
              <div class="title">驾驶证照片</div>
            </el-col>
<!--            {{ detailData?.drivingLicenseTopsideUrl }}-->
            <el-col :span="16">
              <el-image style="width: 320px; height: 200px"
                        :src= detailData?.drivingLicenseTopsideUrl
                        fit="contain" />.
              <el-image style="width: 320px; height: 200px"
                        :src= detailData?.drivingLicenseBacksideUrl
                        fit="contain" />
            </el-col>

<!--            <el-col :span="8">-->
<!--              <div class="title">违规驾驶记录</div>-->
<!--            </el-col>-->
<!--            <el-col :span="16">-->
<!--              <el-image style="width: 180px; height: 100px" src="url" fit="contain" />-->
<!--            </el-col>-->
          </el-row>
        </div>
      </el-col>
    </el-row>

    <footer v-if="detailData?.status == 0">
      <el-button type="primary" style="width: 120px" @click="approvedBtn">通 过</el-button>
      <el-button type="danger" style="width: 120px" @click="rejectBtn">驳 回</el-button>
    </footer>
  </el-dialog>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref, withDefaults } from 'vue'
import api from '@/api/apis/driverExamine'

interface Props {
  show: boolean
  detailId: string
}
const dialog = ref(true)
const props = withDefaults(defineProps<Props>(), {
  show: false,
  detailId: '',
})
const emit = defineEmits<{
  (event: 'update:show', val: boolean): void
  (event: 'reject', val: string): void
  (event: 'approved', val: string): void
}>()
//弹框关闭
const handleClose = () => {
  emit('update:show', false)
}
// 详情数据
const detailData = ref()
onMounted(() => {
  getDetailApi()
})
//获取详情
const getDetailApi = async () => {
  let { data } = await api.getDriverById(props.detailId)
  if (data.code == 200) {
    console.log(data.data)

    detailData.value = data.data
  }
}
//通过
const approvedBtn = () => {
  console.log('000',detailData.value.id)
  emit('approved', detailData.value.id)
}
//驳回
const rejectBtn = () => {
  emit('reject', detailData.value.id)
}
</script>

<style lang="scss">
.ExamineDetailDialog {
  .el-dialog__body {
    padding: 0px 20px 10px;
  }
  .rightBox {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 80%;
    justify-content: space-between;
  }
  .avatarBox {
    display: flex;
    align-items: center;
    margin-right: 20px;
  }
  .my_card {
    border: 1px solid rgba(220, 221, 221, 1);
    border-radius: 10px;
    // padding: 13px 0;
    margin-bottom: 10px;
    .header {
      color: #101010;
      font-size: 16px;
      border-bottom: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      font-weight: 600;
    }
    .flexBetween {
      display: flex;
      width: 100%;
      margin-bottom: 10px;
      justify-content: space-between;
      .leftTitle {
        width: 70px;
        display: inline-block;
      }
    }
    .price {
      display: inline-block;
      width: 30px;
    }
    .fontBold {
      font-weight: bold;
      color: #333;
      font-size: 15px;
    }
    .elrow {
      // text-align: right;
      border-top: 1px solid rgba(220, 221, 221, 1);
      padding: 10px 24px;
      .title {
        font-weight: 600;
        color: #333;
        text-align: left;
      }

      .flexBox {
        display: flex;
        align-items: center;
        p {
          margin: 0 10px;
        }
        .remark {
          color: #a7a7b3;
        }
        .el-icon {
          margin-right: 5px;
        }
      }
      .el-col {
        margin-bottom: 10px;
      }
    }
    .elrow:nth-child(2) {
      border-top: none !important;
    }
    .operate {
      color: #409eff;
      margin-left: 10px;
      cursor: pointer;
    }
  }

  .elrow {
    .el-image {
      margin-right: 10px;
    }
  }
  footer {
    margin: 20px 0 10px;
    text-align: center;
  }
}
</style>
